package com.campus_information_portal.dao;

import com.campus_information_portal.entity.ProjectCondition;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author 20155884 王晓阳
 * @className : FinishProjectDao
 * @Description state=0已拒绝立项||state=1已同意立项||state=2立项审核中||state=3已同意结项||state=4已拒绝结项||state=5结项审核中
 * @create 2018/05/31  10:09$
 **/
public interface FinishProjectDao {

    /**
     * @param
     * @Description 学生查询已同意的立项
     * @author 20155884 王晓阳
     * @methodName
     * @returnType
     * @create 2018/5/31 10:11
     **/
    @Select("SELECT project.*,student.stu_info_id,student.stu_name,student.stu_num ,term.* " +
            "FROM project,student ,term " +
            "WHERE project.stu_info_id=student.stu_info_id AND project.term_id=term.term_id AND project_state<>0 AND project_state<>2 AND project.stu_info_id=#{stuInfoId}")
    List<ProjectCondition> findAgreedProject(ProjectCondition projectCondition);

    /**
     * @param
     * @Description 老师查询已同意的立项
     * @author 20155884 王晓阳
     * @methodName
     * @returnType
     * @create 2018/5/31 10:11
     **/
    @Select("SELECT project.*,student.stu_info_id,student.stu_name,student.stu_num ,term.* " +
            "FROM project,student ,term " +
            "WHERE project.stu_info_id=student.stu_info_id AND project.term_id=term.term_id AND project_state<>0 AND project_state<>1 AND project_state<>2")
    List<ProjectCondition> findAgreedProjectByTea();


    /**
     * @param
     * @Description 结项申请，更新状态为...，正在审核
     * @author 20155884 王晓阳
     * @methodName
     * @returnType
     * @create 2018/5/31 16:00
     **/
    @Update("UPDATE project SET project_state=#{projectCondition.projectState},project_conclusion=#{projectCondition.projectConclusion} WHERE project_id=#{projectCondition.projectId}")
    int updateFinishProject(@Param("projectCondition") ProjectCondition projectCondition);

    /**
     * @param
     * @Description 条件查询社会实践
     * @author 20155884 王晓阳
     * @methodName
     * @returnType
     * @create 2018/5/31 16:30
     **/
    @SelectProvider(type = ProjectSqlProvider.class, method = "queryProject")
    List<ProjectCondition> queryProject(ProjectCondition projectCondition);

    /**
     * @param
     * @Description 根据id查看社会实践
     * @author 20155884 王晓阳
     * @methodName
     * @returnType
     * @create 2018/6/1 14:39
     **/
    @Select("SELECT project.*,student.stu_info_id,student.stu_name,student.stu_num ,term.* " +
            "FROM project,student ,term " +
            "WHERE project.stu_info_id=student.stu_info_id AND project.term_id=term.term_id " +
            "and project_id=#{projectCondition.projectId}")
    ProjectCondition queryProjectById(@Param("projectCondition") ProjectCondition projectCondition);
}
